<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>永中office</title>
<script src="js/bill-ajax.js" type="text/javascript" charset="utf-8"></script>
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://libs.uairobot.com/jquery.form/4.2.1/jquery.form.min.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
<form id='frm1'>
  <input type='file' name='file' />
  <input type='button' id='btn1' value='上传' />
  <input type="button" id="btn2" value='转换' />
</form>
<script type="text/javascript">
var rootName = ajax.getRootName();
var inputDir;
var convertType = 1;
$(function() {
  $("#btn1").click(function() {
    $("#frm1").ajaxSubmit({
      type: "post",
      url: rootName + '/testUpload',
      success: function(r) {
        r = JSON.parse(r);
        inputDir = r.data;
        alert("上传成功");
      }
    });
  });
  $("#btn2").click(function() {
    var uri = rootName + '/convert';
    var param = "inputDir=" + inputDir + "&convertType=" + convertType;
    ajax.post(uri, param, function(r) {
      alert("转换成功,将进行跳转");
      r=JSON.parse(r);
      location.href=r.data[0];
    });
  });
});
</script>
</body>

</html>